home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / qmgr / op_mta.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  4.3 KB  |  199 lines

  1. /* op_mta.c: mta ROS operation routines */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/qmgr/RCS/op_mta.c,v 6.0 1991/12/18 20:23:58 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/qmgr/RCS/op_mta.c,v 6.0 1991/12/18 20:23:58 jpo Rel $
  9.  *
  10.  * $Log: op_mta.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:58  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16. #include "util.h"
  17. #include "qmgr-int.h"
  18. #include "consblk.h"
  19. #include "Qmgr-types.h"
  20. #include <isode/cmd_srch.h>
  21. #include <isode/rosap.h>
  22.  
  23. #define     MTA_READ_INTERVAL    60    /* in secs */
  24.  
  25. /* ARGSUSED */
  26. int arg_mtaread (ad, args, arg)
  27. int                ad;
  28. char                **args; /* args[0] is channel name */
  29. struct type_Qmgr_MtaRead    **arg;
  30. {
  31.     char    *str;
  32.     UTC    utc;
  33.  
  34.     *arg = (struct type_Qmgr_MtaRead *) malloc(sizeof(**arg));
  35.     utc = (UTC) malloc (sizeof(struct UTCtime));
  36.  
  37.     utc->ut_flags = UT_SEC;
  38.     utc->ut_sec = MTA_READ_INTERVAL;
  39.     str = utct2str(utc);
  40.     (*arg)->time = str2qb(str, strlen(str), 1);
  41.  
  42.     (*arg)->channel = str2qb(args[0],
  43.                  strlen(args[0]),
  44.                  1);
  45.     return OK;
  46. }
  47.  
  48. static MtaInfo *convert_PrioritisedMtaList();
  49.  
  50. /* ARGSUSED */
  51. int res_mtaread (ad, id, dummy, result, roi)
  52. int    ad, id, dummy;
  53. register struct type_Qmgr_PrioritisedMtaList    *result;
  54. struct RoSAPindication    *roi;
  55. {
  56.     struct cons_opblk *op;
  57.  
  58.     if ((op = find_copblk(ad, id)) == NULL)
  59.         return NOTOK;
  60.     
  61.     if (op -> fnx)
  62.         (*op -> fnx) (convert_PrioritisedMtaList(result), id);
  63.     free_copblk (op);
  64.     return OK;
  65. }
  66.  
  67. /*   */
  68.  
  69. extern char *mystrtotime();
  70. static CMD_TABLE control_tbl[] = {
  71.     CTRL_ENABLE,    type_Qmgr_Control_start,
  72.     CTRL_DISABLE,    type_Qmgr_Control_stop,
  73.     CTRL_CACHECLEAR,type_Qmgr_Control_cacheClear,
  74.     CTRL_CACHEADD,    type_Qmgr_Control_cacheAdd,
  75.     NULLCP,        NOTOK
  76.     };
  77.  
  78. /* ARGSUSED */
  79. int arg_mtacontrol (ad, args, arg)
  80. int                ad;
  81. char                **args;
  82. struct type_Qmgr_MtaControl    **arg;
  83. /* args[0] = channel */
  84. /* args[1] = mta */
  85. /* args[2] = stop,start,clear,cacheadd */
  86. /* args[3] = time */
  87. {
  88.     int n;
  89.  
  90.     *arg = (struct type_Qmgr_MtaControl *) malloc(sizeof(**arg));
  91.     (*arg)->control = (struct type_Qmgr_Control *)
  92.         malloc(sizeof(struct type_Qmgr_Control));
  93.  
  94.     (*arg)->channel = str2qb(args[0], strlen(args[0]), 1);
  95.     (*arg)->mta = str2qb(args[1], strlen(args[1]), 1);
  96.  
  97.     if ((n = cmd_srch (args[2], control_tbl)) == NOTOK)
  98.         return NOTOK;
  99.  
  100.     if (((*arg)->control->offset = n) == type_Qmgr_Control_cacheAdd) {
  101.         char    *timestr;
  102.  
  103.         timestr = mystrtotime(args[3]);
  104.         (*arg)->control->un.cacheAdd = str2qb(timestr,strlen(timestr),1);
  105.         free(timestr);
  106.     }
  107.     return OK;
  108. }
  109.  
  110. static MtaInfo *convert_MtaInfo();
  111.  
  112. /* ARGSUSED */
  113. int res_mtacontrol (ad, id, dummy, result, roi)
  114. int    ad, id, dummy;
  115. register struct type_Qmgr_MtaInfo    *result;
  116. struct RoSAPindication    *roi;
  117. {
  118.     struct cons_opblk *op;
  119.  
  120.     if ((op = find_copblk(ad, id)) == NULL)
  121.         return NOTOK;
  122.     
  123.     if (op -> fnx)
  124.         (*op -> fnx) (convert_MtaInfo(result), id);
  125.     free_copblk(op);
  126.     return OK;
  127. }
  128.  
  129. /*   */
  130.  
  131. static MtaInfo    *convert_MtaInfo(pepsy)
  132. register struct type_Qmgr_MtaInfo    *pepsy;
  133. {
  134.     MtaInfo    *ret;
  135.  
  136.     if (pepsy == (struct type_Qmgr_MtaInfo *) NULL)
  137.         return (MtaInfo *) NULL;
  138.  
  139.     ret = (MtaInfo *) calloc (1, sizeof(*ret));
  140.  
  141.     ret->channel = qb2str(pepsy->channel);
  142.     ret->mta = qb2str(pepsy->mta);
  143.     ret->oldestMessage = convert_time(pepsy->oldestMessage);
  144.     ret->numberMessages = pepsy->numberMessage;
  145.     ret->volumeMessages = pepsy->volumeMessages;
  146.     ret->status = convert_ProcStatus(pepsy->status);
  147.     ret->numberReports = pepsy->numberDRs;
  148.     ret->active = pepsy->active;
  149.     if (pepsy->info)
  150.         ret->info = qb2str(pepsy->info);
  151.  
  152.     return ret;
  153. }
  154.  
  155. static MtaInfo *convert_PrioritisedMtaList(pepsy)
  156. register struct type_Qmgr_PrioritisedMtaList    *pepsy;
  157. {
  158.     MtaInfo    *head, *tail, *temp;
  159.  
  160.     head = tail = (MtaInfo *) NULL;
  161.     
  162.     while (pepsy != (struct type_Qmgr_PrioritisedMtaList *) NULL) {
  163.         if ((temp =
  164.              convert_MtaInfo(pepsy->PrioritisedMta->mta))
  165.             == (MtaInfo *) NULL) {
  166.             free_MtaInfo(head);
  167.             return (MtaInfo *) NULL;
  168.         }
  169.         temp -> priority =
  170.             pepsy->PrioritisedMta->priority->parm;
  171.         if (head == NULL)
  172.             head = tail = temp;
  173.         else {
  174.             tail -> next = temp;
  175.             tail = temp;
  176.         }
  177.         pepsy = pepsy -> next;
  178.     }
  179.     return head;
  180. }
  181.  
  182. /*   */
  183.  
  184. free_MtaInfo(list)
  185. MtaInfo    *list;
  186. {
  187.     MtaInfo    *temp;
  188.  
  189.     while (list != (MtaInfo *) NULL) {
  190.         if (list -> channel) free (list -> channel);
  191.         if (list -> mta) free (list -> mta);
  192.         if (list -> status) free_ProcStatus (list -> status);
  193.         if (list -> info) free (list -> info);
  194.         temp = list;
  195.         list = list -> next;
  196.         free ((char *) temp);
  197.     }
  198. }
  199.